// vue.config.js
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  publicPath: '/earthsdk-vue-test',
  outputDir: 'dist',
  assetsDir: 'static',
  chainWebpack: config => {
    config.resolve.alias
        .set("@", resolve("src"))

  },
  configureWebpack: config => {
    const cwp = new CopyWebpackPlugin([
      {
        from: './node_modules/cesium/Build/Cesium', // 调试时，将Cesium换成CesiumUnminified
        to: 'js/Cesium',
        toType: 'dir'
      },
      {
        from: './node_modules/earthsdk/dist/XbsjCesium',
        to: 'js/earthsdk/XbsjCesium',
        toType: 'dir'
      },
      {
        from: './node_modules/earthsdk/dist/XbsjEarth',
        to: 'js/earthsdk/XbsjEarth',
        toType: 'dir'
      },
      {
        from: './src/js',
        to: 'js/earthsdk/XbsjEarth-Plugins',
        toType: 'dir'
      },
      {
        from: './src/assets/img/ht',
        to: 'assets/ht/',
        toType: 'dir'
      },
      {
        from: './src/assets/img/city',
        to: 'assets/city/',
        toType: 'dir'
      },
      {
        from: './src/assets/img/myicon',
        to: 'assets/myicon/',
        toType: 'dir'
      },
      {
        from: './src/assets/json',
        to: 'assets/json/',
        toType: 'dir'
      }
    ]);
    config.plugins.push(cwp);
  }
}
